#!/usr/bin python3
# -*- coding: utf-8 -*-


def analysis(t, tmp:list, length:list) -> str:
    res = []
    for i in range(t):
        if length[i] != '11':
            res.append("NO")
        index = tmp[i].find('8')

        if index == -1 or int(length[i]) - index < 11:
            res.append("NO")
        else:
            res.append("YES")
    return res


if __name__ == '__main__':
    t = input()
    length = []
    tmp = []
    for i in range(1, 2 * int(t) + 1):
        if i % 2 == 1:
            length.append(input())
        elif i % 2 == 0:
            tmp.append(input())
    result = analysis(int(t), tmp, length)

    for i in result:
        print(i)
